package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: ProjectAuthServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-20
 * @Version: 1.0
 * Table: pear_project_auth
 * Comment:
 * 项目权限表
 */
@Service
public class ProjectAuthServiceImpl extends ProjectAuthServiceCustomImpl implements ProjectAuthService {

    static {
        beanClassNameMap.put("project_auth", "projectAuthServiceImpl");
        listMethodNameMap.put("project_auth", "listProjectAuth");
        listMethodParameterClassNameMap.put("project_auth", "ProjectAuthQueryRequest");
        updateMethodNameMap.put("project_auth", "updateProjectAuth");
        updateMethodParameterClassNameMap.put("project_auth", "ProjectAuthUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addProjectAuth(ProjectAuthAddRequest request) throws Exception {
        super.fixRequest("project_auth", "add", request);
        return super.addProjectAuth(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateProjectAuth(ProjectAuthUpdateRequest request) throws Exception {
        ProjectAuth record = null;
        record = projectAuthMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("project_auth", "update", request, record);
        return super.updateProjectAuth(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteProjectAuth(ProjectAuthDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<ProjectAuth> list = null;
            ProjectAuthExample example = new ProjectAuthExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = projectAuthMapper.selectByExample(example);
            fixRequest("project_auth", "delete", request, list);
        } else {
            fixRequest("project_auth", "delete", request);
        }
        return super.deleteProjectAuth(request);
    }

    @Override
    public ProjectAuthQueryResponse queryProjectAuth(ProjectAuthQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        ProjectAuthQueryResponse result = super.queryProjectAuth(request);
        checkResult("project_auth", "query", request, result);
        return result;
    }

    @Override
    public List<ProjectAuthQueryResponse> listProjectAuth(ProjectAuthQueryRequest request) throws Exception {
        List<ProjectAuthQueryResponse> list = super.listProjectAuth(request);
        checkResult("project_auth", "list", request, list);
        return list;
    }

    @Override
    public Integer countProjectAuth(ProjectAuthQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_auth", "count", request);
        return super.countProjectAuth(request);
    }

    @Override
    public BaseStatResponse statProjectAuth(ProjectAuthQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_auth", "stat", request);
        return super.statProjectAuth(request);
    }

}
